package com.losl.framework.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import com.losl.framework.web.service.AutoDataInject;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author Maxwell
 */
@Configuration
@MapperScan(basePackages = "com.losl.system.mapper")
public class MybatisPlusConfig {
    /* Mybatis-Plus的分页插件 */
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
        return interceptor;
    }

    /**
     * 通用属性自动填充
     */
    @Bean
    public AutoDataInject autoDataInject(){
        return new AutoDataInject();
    }

}
